<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
    session_start();
    if("staff"==$_SESSION['level']){
        $url1="User.php";
        $url2="CheckAttendanceForStaff.php";
        $url3="DailyAssignmentForStaff.php";
        $url4="BulletinForStaff.php";
        $url5="Attendancechart.php";
    }
    else if("manager"==$_SESSION['level']){
        $url1="Namelist.php";
        $url2="CheckAttendanceForManager.php";
        $url3="DailyAssignment.php";
        $url4="BulletinForManager.php";
        $url5="AttendanceStatistics.php";
    }
    if($_SESSION['login']!='y'){
        $url = 'login.html';
        Header("Location: $url");
    }
    error_reporting(0);
    $year=$_POST['year'];
    /*$time = time();
  $date = getdate($time);
  $year = $date["year"];
  $mon = $date["mon"];
  $day = $date["mday"];*/
    include('class.php');
    $db = new DB();
    
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript" src="jqplot.js"></script>

<link rel="stylesheet" href="bootstrap-theme.css">
        <link rel="stylesheet" href="bootstrap-theme.min.css">
        <link rel="stylesheet" href="bootstrap.min.css">
        <link rel="stylesheet" href="bootstrap.css">
		<link rel="stylesheet" href="DIY.css">

</head>
<body>
<div class="container">
<ul class="nav nav-tabs">
  <li role="presentation"><a href= <?php echo $url1 ; ?> >Staff Information</a></li>
  <li role="presentation" ><a href= <?php echo $url2 ; ?> >Check Attendance</a></li>
  <li role="presentation" class="active"><a href= <?php echo $url5 ; ?> >Attendance Statistics</a></li>
  <li role="presentation"><a href= <?php echo $url3 ; ?> >Daily Assignment</a></li>
  <li role="presentation"><a href= <?php echo $url4 ; ?> >Bulletin</a></li>
  <a class="logout" href="Logout.php">Log out</a>
  <label class="logout">Company Name</label>
  
</ul>
    <div class="panel panel-default">
 
</div>
<div class="panel panel-default">
<div class="panel-heading">
    <h3 class="panel-title">Attendance Statistics</h3>
    <form method="post" action="Attendancechart.php">
                    <select name="year" id="year">
                                            <option value="2015">2015</option>
                                           <option value="2016">2016</option>
                                           <option value="2017">2017</option>
                    </select>
                        <button type="submit">Confirm</button>
                        </form>
    <?php echo $year ?>
  </div>
    <div class="panel-body chart">
	<div id="chart1"></div>

<div style="text-align:center;clear:both;">
<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>

	<div id="chart2"></div>
    </div>
    </div>
	<script type="text/javascript">
    /*var data=new Array();
    var k=1;
    for(var j=0;j<2;j++){
        data[j]=new Array();
        for(var i=0;i<12;i++){
        data[j][i]=k;
        k++;
    }
    }*/
    var data=new Array();
    //data=[1,2,3,4,5,6,7,8,9];
    <?php
        
        $Jan=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'1');
        $Feb=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'2');
        $Mar=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'3');
        $Apr=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'4');
        $May=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'5');
        $Jun=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'6');
        $Jue=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'7');
        $Aug=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'8');
        $Sep=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'9');
        $Oct=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'10');
        $Nov=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'11');
        $Dec=$db->getAttendancein($_SESSION['name'],$_SESSION['id'],$year,'12');
        
        $Jan1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'1');
        $Feb1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'2');
        $Mar1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'3');
        $Apr1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'4');
        $May1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'5');
        $Jun1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'6');
        $Jue1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'7');
        $Aug1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'8');
        $Sep1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'9');
        $Oct1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'10');
        $Nov1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'11');
        $Dec1=$db->getAttendancefo($_SESSION['name'],$_SESSION['id'],$year,'12');
        
        //echo $Sep1. $Sep. $Nov1. $Nov1;
        ?>
    var a1=<?php echo $Jan ?>;
    var b1=<?php echo $Feb ?>;
    var c1=<?php echo $Mar ?>;
    var d1=<?php echo $Apr ?>;
    var e1=<?php echo $May ?>;
    var f1=<?php echo $Jun ?>;
    var g1=<?php echo $Jue ?>;
    var h1=<?php echo $Aug ?>;
    var i1=<?php echo $Sep ?>;
    var j1=<?php echo $Oct ?>;
    var k1=<?php echo $Nov ?>;
    var l1=<?php echo $Dec ?>;
    
    var a2=<?php echo $Jan1 ?>;
    var b2=<?php echo $Feb1 ?>;
    var c2=<?php echo $Mar1 ?>;
    var d2=<?php echo $Apr1 ?>;
    var e2=<?php echo $May1 ?>;
    var f2=<?php echo $Jun1 ?>;
    var g2=<?php echo $Jue1 ?>;
    var h2=<?php echo $Aug1 ?>;
    var i2=<?php echo $Sep1 ?>;
    var j2=<?php echo $Oct1 ?>;
    var k2=<?php echo $Nov1 ?>;
    var l2=<?php echo $Dec1 ?>;
    
    

	data = [[a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1],[a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2]];
	var data_max = 35; 
	var line_title = ["Work","Offday"]; 
	var y_label = "Number of days"; 
	var x_label = "Month"; 
	var x = [1,2,3,4,5,6,7,8,9,10,11,12]; 
	var title = "The detail statistics of this staff "; 
	j.jqplot.diagram.base("chart1", data, line_title, "The detail statistics of this staff ", x, x_label, y_label, data_max, 1);
	j.jqplot.diagram.base("chart2", data, line_title, "The detail statistics of this staff ", x, x_label, y_label, data_max, 2);

</script>
    </div>
</body>
</html>

